﻿<html xmlns:th="http://www.thymeleaf.org">
<head>
    <!--资源获取-->
    <base th:href="|${#request.getContextPath()}/|">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="static/lib/html5shiv.js"></script>
    <script type="text/javascript" src="static/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="static/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="static/lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--layui-->
    <link rel="stylesheet" type="text/css" href="static/layui/css/layui.css"/>

    <script type="text/javascript" src="static/layui/layui.js"></script>
    <title>资讯列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    首页
    <span class="c-gray en">&gt;</span>
    模拟投资
    <span class="c-gray en">&gt;</span>
    最新投资
    <a  class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>

    <a id="djsc" class="btn btn-success radius r " style="line-height:1.6em;margin-top:3px"
       href="javascript:;"  title="收藏">

        <i id="sc" class=" Hui-iconfont" >&#xe69d;</i>
        <i id="qxsc" class=" Hui-iconfont">&#xe69e;</i></a>
</nav>
<div class="page-container">

    <table class="layui-hide" id="zxtz" lay-filter="zxtz"></table>



    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
            <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
            <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
        </div>
    </script>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">详细</a>
    </script>



    <script type="text/javascript" src="static/lib/jquery/1.9.1/jquery.min.js"></script>

    <script type="text/javascript" src="static/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="static/lib/laypage/1.2/laypage.js"></script>
    <script>
        /*收藏按钮*/
        var ejhref = "Investment/NewInvestment";//收藏路径
        $.ajax({
            url:"CollectionPage?page="+ejhref,
            async:false,
            type:"GET",
            success:function(datas){
                if(datas=="sc"){

                    $("#qxsc").addClass("layui-hide");
                    $("#sc").addClass("layui-show");

                }else {
                    $("#sc").addClass("layui-hide");
                    $("#qxsc").addClass("layui-show");
                }
            }
        })
        $("#djsc").on("click",function () {

            $.ajax({
                url:"CollectionNewPage",
                type:"POST",
                data: {
                    "page":ejhref,
                    "pageName":"最新投资"//收藏名字
                },
                success:function (regas) {
                    if(regas!="sc"){

                        $("#qxsc").attr("class","Hui-iconfont layui-hide");
                        $("#sc").attr("class","Hui-iconfont layui-show");

                    }else {
                        $("#sc").attr("class","Hui-iconfont layui-hide");
                        $("#qxsc").attr("class","Hui-iconfont layui-show");
                    }

                }
            })

        })
        /*收藏按钮*/


        /*时间转换*/
        function GetNumberOfDays(date1,date2){//获得天数
            //date1：开始日期，date2结束日期
            var a1 = Date.parse(new Date(date1));
            var a2 = Date.parse(new Date(date2));
            var day = parseInt((a2-a1)/ (1000 * 60 * 60 * 24));//核心：时间戳相减，然后除以天数
            return day
        };
        layui.use('table', function(){
            var table = layui.table;

            table.render({
                elem: '#zxtz'
                ,url:'/Investment/SelectNewInvestment'
                ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                ,defaultToolbar: ['filter', 'exports', 'print', ]
                ,title: '最新投资'
                ,cols: [
                    [
                    {type: 'checkbox', fixed: 'left'}

                        ,{ field: 'lx', title: '类型'}
                    ,{field:'totle', title:'名字', width:420 ,templet(res){
                        return '<em title=\"'+res.remarks+'">'+ res.totle +'</em>';
                        }}
                    ,{field:'startTime', title:'开始时间', width:200,sort: true}
                    ,{field:'endTime', title:'结束时间', width:200,sort: true}
                    ,{field:'SurplusTime', title:'剩余时间', width:100,sort: true, templet: function(res){
                            return '<em>'+ GetNumberOfDays( Date.now(), res.endTime) +'</em>'
                        }}
                    ,{field:'amount', title:'金额',sort: true, templet: function(res){
                        if(res.zh.amount != null){
                            return '<em>'+ res.zh.amount  +'</em>';
                        }else
                            return '<em><a href="/Investment/NewUserZh?zqId='+res.zqId+'&uId='+[[${session.session_user.uId}]]+'" id="canyu"> '+ '点击参与'  +'</a></em>'
                        }}

                ]
                ]
                ,page: true
            });


            //头工具栏事件
            table.on('toolbar(zxtz)', function(obj){
                var checkStatus = table.checkStatus(obj.config.id);
                switch(obj.event){
                    case 'getCheckData':
                        var data = checkStatus.data;
                        layer.alert(JSON.stringify(data));
                        break;
                    case 'getCheckLength':
                        var data = checkStatus.data;
                        layer.msg('选中了：'+ data.length + ' 个');
                        break;
                    case 'isAll':
                        layer.msg(checkStatus.isAll ? '全选': '未全选');
                        break;


                };
            });

            //监听行工具事件
            table.on('tool(zxtz)', function(obj){
                var data = obj.data;
                //console.log(obj)
                console.log(obj);
                 if(obj.event === 'edit'){
                    layer.open({
                        Type: 2,
                        title :'我是标题',
                        area: ['70%', '70%'],
                        fixed: false, //不固定
                        maxmin: true,
                        content: 'test/iframe'})
                }
            });
        });
    </script>

<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="static/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
<script type="text/javascript">

</script>
</div>
</body>
</html>
